<template>
  <view v-if="shenheStatus == 0" class="cash">

    <view class="input-box">
      <view class="input-title">{{ $t('admin.input') }}{{ $t("common.orderPrice") }}</view>
      <view class="input">
        <view>￥</view>
        <view>
          <u-input v-model="inputNum" placeholder="0.00" type="digit"></u-input>
        </view>
      </view>
    </view>


    <!-- 提交button -->
    <view @click="submit" class="btn flex-y-center flex-x-center">{{
      $t("person.confirmCancle")
    }}</view>

  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
import { voucherClerk } from "@/api/alipay/coupon";
export default {
  components:{
        Shenhe,
  },
  data() {
    return {
      inputNum: "", //输入提现金额
      ov: "",
    };
  },
  onLoad(t) {
      this.ov = t.ov;
  },
  onShow() {
    // 获取个人数据
  },
  methods: {
    async submit() {
      var reg1 = /^[0-9]+(\.[0-9]{0,2})?$/;
      if (!reg1.test(this.inputNum))
        return this.$utils.toast(this.$t('mdAdmin.confirmOrderMoney'));

      voucherClerk({ov: this.ov, total_price: this.inputNum}).then(res => {
        if (!res.code) {
          uni.showModal({
            success: res => {
              uni.navigateBack();
            },
            content: '核销成功。\n\n优惠金额：￥' + res.sub_price + '\n\n优惠类型：' + (res.coupon.discount_type == 1 ? (res.coupon.discount + '折') : '满减'),
          })
        }
      }).catch(res => {
        uni.showModal({
          success: res => {
            uni.navigateBack();
          },
          content: res.msg,
        })
      });
    },
  },
  computed: {
  },
};
</script>

<style lang="scss" scoped>
.cash {
  color: #262626;
  font-family: PingFang SC;
  padding: 0 36rpx;
}
.way {
  height: 102rpx;
  border-bottom: 2rpx solid #f1f1f1;
  > view:nth-child(1) {
    height: 42rpx;
    font-size: 30rpx;
    font-weight: 600;
  }
  > view:nth-child(2) {
    height: 40rpx;
    font-size: 28rpx;
    .iconfont {
      font-size: 44rpx;
      &:nth-child(1) {
        margin-right: 10rpx;
      }
    }
    > text:nth-child(2) {
      margin-top: -2rpx;
    }
  }
}
.input-box {
  .input-title {
    padding: 30rpx 0;
    line-height: 42rpx;
    font-size: 30rpx;
    font-weight: 600;
  }
  .input {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f1f1;
    padding-bottom: 20rpx;
    > view:nth-child(1) {
      font-size: 40rpx;
      font-weight: 600;
      transform: translateY(8rpx);
    }
    > view:nth-child(2) {
      flex: 1;
      width: 0;
      /deep/.u-input__input {
        font-size: 56rpx;
        font-weight: 600;
        height: 112rpx;
        color: #262626;
      }
    }
  }
}

.all-withdrawal {
  margin-top: 28rpx;
  margin-bottom: 80rpx;
  height: 34rpx;
  font-size: 24rpx;
  color: #8c8c8c;
}

.btn {
  width: 678rpx;
  height: 88rpx;
  background: #f0250e;
  opacity: 1;
  border-radius: 120rpx;
  font-size: 32rpx;
  font-weight: 500;
  color: #ffffff;
}

.popup-box {
  width: 600rpx;
  padding: 0 50rpx;
  color: #262626;
  .title {
    height: 90rpx;
    line-height: 90rpx;
    font-size: 32rpx;
    font-weight: 600;
    text-align: center;
  }
  .popup-item {
    height: 100rpx;
    border-bottom: 1px solid #f1f1f1;
    font-size: 28rpx;
    .iconfont {
      font-size: 50rpx;
      margin-right: 15rpx;
    }
  }
}
</style>
